<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="box" class="one" data-test="qq" clear="testttt">123</div>

  <script>
    var div= document.querySelector('div')

    console.log( div.id )
    // class
    console.log( div.className )

    console.log( div['data-test'] )  // 自定义属性

    console.log( div.getAttribute('data-test') )  // qq  // 获取自定义属性
    div.setAttribute('data-test', 'wechart')  // 设置自定义属性
    div.removeAttribute('clear')
  </script>
</body>
</html>